package com.example.demo.huawei;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

/**
 * 最大n个数 与最小 n个数之和 去重
 */
/*
5
3 2 3 4 2
2
输出-1
5
95 88 83 64 100
2
输出342
 */
public class OD35 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            if (a < 0 || a > 1000) {
                System.out.println(-1);
                return;
            }
            set.add(a);
        }
        List<Integer> list = new ArrayList<>(set);
        // 最大最小n个数
        int n = sc.nextInt();
        //        System.out.println(m);
        //        System.out.println(n);
        //        System.out.println(list);
        if (n == 0) {
            System.out.println(0);
            return;
        }
        if (list.size() < 2 * n) {
            System.out.println(-1);
            return;
        }
        Collections.sort(list);
        int left = 0;
        int right = list.size() - 1;
        int sum = 0;
        int num = 0;
        while (left < right && num <= n) {
            sum = sum + list.get(left) + list.get(right);
            num++;
            left++;
            right--;
        }


        System.out.println(sum);
    }
}
